/**
 * @program: 1.15 栈和队列
 * @description:
 * @author: 李鑫月
 * @create: 2022-01-16 09:42
 **/
class  Node{
    public int val;
    public Node next;
    public Node(int val){
        this.val=val;
    }
}
public class MyQueue {
    public Node head;
    public  Node last;
    public  void offer(int val){
        Node node =new Node(val);
        if(this.head==null){
            head=node;
            last=node;
        }else{
            last.next=node;
            last=node;
        }
    }
    public int poll(){
        if(isEmpty()){
            throw new RuntimeException("队列为空");
        }else{
            int ret= head.val;
            head=head.next;
            return  ret;
        }

    }
    public  int peek(){
        if(isEmpty()){
            throw new RuntimeException("队列为空");
        }else{
            int ret= head.val;
            return  ret;
        }
    }
    public boolean isEmpty(){
        return this.head==null;
    }
}
